package com.safe.first.domain.user;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.safe.first.common.ddd.AbstractEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.time.Instant;
import java.util.Collection;
import java.util.List;

/**
 * @author Mickey
 * @since 2021/10/28
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "sf_user")
public class DefaultUser extends AbstractEntity implements User , UserDetails {

    private String avatar;
    private String mobile;
    private String username;
    private String password;
    private Instant birthday;
    @TableField(typeHandler = UserLoginWay.LoginWayArrayType.class)
    private List<UserLoginWay> loginWay;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
